﻿<link type="text/css" href="~/Scripts/TimePicker/jquery-ui-timepicker-addon.css" rel="Stylesheet" />
<script type="text/javascript" src="~/Scripts/TimePicker/jquery-ui-timepicker-zh-CN.js"></script>
<script type="text/javascript" src="~/Scripts/TimePicker/jquery.ui.datepicker-zh-CN.js" charset="UTF-8"></script>
<div>
    <label for="startTime" style="margin-left: 15px;">开始时间:</label>
    <input id="startTime" type="text" value="@ViewBag.StartTime"  class = "ui_timepicker" readonly="readonly" style="width: 155px;"/>
    <label for="endTime">结束时间:</label>
    <input id="endTime" type="text" value="@ViewBag.EndTime"  class = "ui_timepicker" readonly="readonly" style="width: 155px;"/>
    @*<label for="stopInterval">区域类型:</label>
    <select id="regionType">
        <option value="0">全部类型</option>
        <option value="1">进出站点</option>
        <option value="2">进出工地</option>
    </select>*@
    <input type="button" id="searchBtn" style="width: 50px;" value="查询" />
</div>
<script type="text/javascript">
    $(function () {
        // 时间设置
        $('.ui_timepicker').datetimepicker({
            timeFormat: "HH:mm:ss",
            dateFormat: "yy-mm-dd",
            showSecond: true,
            stepHour: 1,
            stepMinute: 1,
            stepSecond: 1
        });

    });

    $("#searchBtn").click(function () {
        if ($("#startTime").val().toString() > $("#endTime").val().toString()) {
            artDialogAlert("开始时间不得大于结束时间");
            return false;
        }
        var treeObj = $.fn.zTree.getZTreeObj("tree");
        var vehicles = treeObj.getCheckedNodes();
        if (vehicles.length == 0) {
            artDialogAlert("请先选择要查询的车辆或单位");
            return false;
        }

        var v = "";
        $.each(vehicles, function (index) {
            if (vehicles[index].sim && vehicles[index].sim != null) {
                v += (vehicles[index].sim + ";");
            }
        });
        v = v.substring(0, v.length - 1);
        $("#vehicles").val(v);
        var url = $("#reporturl").val() + '?startTime=' + $("#startTime").val() + '&endTime=' + $("#endTime").val();
        //var params='{startDate:"'+$("#startDate").val()+'",endDate:"'+$("#endDate").val()+'",vehicles:"'+v+'"}';
        //var params = 'startDate=' + $("#startDate").val() + '&endDate=' + $("#endDate").val() + '&vehicles=' + v;
        artDialogFormWithCallback(url,
            $("#reporttext").val(),
            "search",
            Number($("#reportwidth").val()),
            Number($("#reportheight").val()),
            null,
            //对话框关闭时执行回调函数清除session
            function () {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "/ReportCenter/ClearSession",
                    data: {},
                    error: function (data) {
                        artDialogAlert("清楚数据失败");
                    }
                });
            });
    });
</script>

